package com.flea.hclv.controller;

import com.flea.hclv.model.entity.HCustomerManage;
import com.flea.hclv.model.entity.vo.HCustomerManageVo;
import com.flea.hclv.service.HCustomerManageService;
import com.flea.hclv.util.ServerResponse;
import com.flea.system.bean.FleaPage;
import com.flea.system.entity.OrgDept;
import com.flea.system.platform.session.FleaOrgUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @program: project
 * @description: 客户缴费管理
 * @author: shiliqiang
 * @create: 2018-11-10 14:14
 * @version: 1.0
 */
@Controller
@RequestMapping("/flea/hclv/customer/manage/")
public class HCustomerManageController {

    @Autowired
    private HCustomerManageService hCustomerManageService;

    @RequestMapping("save")
    @ResponseBody
    public ServerResponse<HCustomerManage> save(HttpServletRequest request, String model){
        String userId = FleaOrgUtils.getCurUserUuid(request);
        return hCustomerManageService.save(userId,model);
    }

    @RequestMapping("customerPay")
    @ResponseBody
    public ServerResponse<String> saveCustomerPay(HttpServletRequest request, String model){
        String userId = FleaOrgUtils.getCurUserUuid(request);
        return hCustomerManageService.saveCustomerPay(userId,model);
    }

    @RequestMapping("update")
    @ResponseBody
    public ServerResponse<String> update(HttpServletRequest request, String model){
        String userId = FleaOrgUtils.getCurUserUuid(request);
        return hCustomerManageService.update(userId,model);
    }

    @RequestMapping("selectAll")
    @ResponseBody
    public ServerResponse<FleaPage<HCustomerManageVo>> select(FleaPage<HCustomerManage> paging,
                                                              @RequestParam(value = "queryName", defaultValue = "")String queryName,
                                                              @RequestParam(value = "queryStartTime", defaultValue = "")String queryStartTime,
                                                              @RequestParam(value = "queryEndTime", defaultValue = "")String queryEndTime,
                                                              @RequestParam(value = "serviceType", defaultValue = "")String serviceType
//                                                              @RequestParam(value = "queryStatus", defaultValue = "")String queryStatus
    ){
        return hCustomerManageService.select(queryName,queryStartTime,queryEndTime,serviceType,
                paging.getCurPage(),paging.getPageSize());
    }

    @RequestMapping("selectAllDept")
    @ResponseBody
    public ServerResponse<List<OrgDept>> selectAllDept(){
        return hCustomerManageService.selectAllDept();
    }



}
